--
-- Author: shunguo.chen
-- Date: 2018-12-03 10:50:51
--
-- TeamRecruitInfoVo 队伍招募信息数据结构
-- 

local fileName = string.getModeName(...)
local ClassRef = class(fileName)

-- message RecruitInfo {
--    int32 targetID   = 2; //队伍招募目标(服务器)ID3
--    int32 minLevel   = 3; //队伍招募玩家最小等级
--    int32 maxLevel   = 4; //队伍招募玩家最小等级
--    bool needTank    = 5; //队伍需要坦克
--    bool needDPS     = 6; //队伍需要输出
--    bool needHeal    = 7; //队伍需要治疗
--    bool autoApprove = 8; //是否自动批准
--    bool autoRecruit  = 9; //是否自动招募
--    string memoText  = 10;//招募文本
--    string memoAudio = 11;//招募语音
-- }
function ClassRef:ctor(data)
	self.targetID = 0
	self.minLevel = 0
	self.maxLevel = 0
	self.needTank = false
	self.needDPS = false
	self.needHeal = false
	self.autoApprove = false -- 自动同意申请
	self.autoRecruit = false -- 自动针对目标招募
	self.memoText = ""
	self.memoAudio = ""

	-- 本地缓存的
	self.audioPath = ""
	self.audioDuration = 0

	if data then
		self:read(data)
	end
end

function ClassRef:read(data)
	self.targetID = data.targetID or 0

	self.minLevel = data.minLevel or 0
	self.maxLevel = data.maxLevel or 0

	self.needTank = data.needTank or false
	self.needDPS = data.needDPS or false
	self.needHeal = data.needHeal or false
	self.autoApprove = data.autoApprove or false
	self.autoRecruit = data.autoRecruit or false
	self.memoText = data.memoText or ""
	self.memoAudio = data.memoAudio or ""

	-- 本地缓存的
	self.audioPath = self.audioPath or ""
	self.audioDuration = self.audioDuration or 0
end

function ClassRef:hasAudio()
	return self.memoAudio ~= ""
end

function ClassRef:hasAudioFile()
	return self.audioPath ~= ""
end

function ClassRef:setTeamTargetVo(teamTargetVo)
    self.teamTargetVo = teamTargetVo
end

function ClassRef:getTeamTargetId()
    return self.targetID
end

function ClassRef:isAutoApprove()
	return self.autoApprove
end

function ClassRef:isAutoRecruit()
	return self.autoRecruit
end

-- 判断参数lv是否落在 self.minLevel ==>> self.maxLevel 区间之内
function ClassRef:isLvLocateBetweenMinMaxLv( level )
	return tonumber( self.minLevel ) <= tonumber( level ) and tonumber( level ) <= tonumber( self.maxLevel )
end

-- 判断参数 skillChooseId 是否是本设置需求的职责
function ClassRef:isClassIdNeeded( skillChooseId )
	local skillChoosesConf = GD:getSpecSkillChoose( tonumber( skillChooseId ) )
	local dutyClassTemp = tonumber( skillChoosesConf.dutyClass )
	if 1 == dutyClassTemp then
		return self.needTank
	elseif 2 == dutyClassTemp then
		return self.needDPS
	elseif 3 == dutyClassTemp then
		return self.needHeal
	end
	return false
end

-- 获得创建队伍的recruitInfo
function ClassRef:getCreateRecruitInfo(targetId, autoRecruit)
	local info = {}
	info.targetID = targetId or 0
	info.minLevel = 1
	info.maxLevel = tonumber(GD:getSystemPar("maxlvforpro",60))
	info.needTank = true
	info.needDPS = true
	info.needHeal = true
	info.autoApprove = true
	if type(autoRecruit) == "nil" then
		info.autoRecruit = false
	else
		info.autoRecruit = autoRecruit
	end
	info.memoText = ""
	info.memoAudio = ""
	return info
end

function ClassRef:clone()
	local temp = {}
	temp.targetID = self.targetID
	temp.minLevel = self.minLevel
	temp.maxLevel = self.maxLevel
	temp.needTank = self.needTank
	temp.needDPS = self.needDPS
	temp.needHeal = self.needHeal
	temp.autoApprove = self.autoApprove
	temp.autoRecruit = self.autoRecruit
	temp.memoText = self.memoText
	temp.memoAudio = self.memoAudio
	return temp
end

function ClassRef:cloneVo()
	local temp = self:clone()
	local vo = ClassRef.new(temp)
	vo.audioPath = self.audioPath
	vo.audioDuration = self.audioDuration
	return vo
end

function ClassRef:isEqual( temp )
	assert( temp, " ------------------>>>>> TeamRecruitInfoVo 不支持与nil数据比较 " )

	for k,v in pairs(temp) do
		if v ~= self[k] then
			return false
		end
	end
	return true
end

-- 返回队伍目标 + 招募文本
function ClassRef:getPulishWords()
	local dungeonName = ""
	print("getPulishWords", teamTargetVo and teamTargetVo.id)
	if self.teamTargetVo then
		dungeonName = self.teamTargetVo:getTeamReqStr()
	end
	return dungeonName
end

return ClassRef
